﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using CardLogistics.Web.Components;

namespace CardLogistics.Web.MainPage.CardMaking.CardOutStorage
{
    public partial class Detail : BasePage
    {
        private static readonly CardLogistics.DAL.CardMaking.CardMaking_CardOutStorageData DAL = new CardLogistics.DAL.CardMaking.CardMaking_CardOutStorageData();
        private static readonly CardLogistics.DAL.CardMaking.CardMaking_CardOutStrgeDetailData DDAL = new CardLogistics.DAL.CardMaking.CardMaking_CardOutStrgeDetailData();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                InitControl();
            }
        }
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public void InitControl()
        {
            string _key = Request.QueryString["id"];
            WebUserControl_AppInfo1.InfoID = _key;
            WebUserControl_AppInfo1.UserID = LoggedUser.ID;
            if (!string.IsNullOrEmpty(_key))
            {
                CardLogistics.Model.CardMaking.CardMaking_CardOutStorage pData = DAL.GetModel(_key);
                SetWebControls(this.Page, pData);
                if (pData != null)
                {
                    //出库日期
                    if (pData.OUTSTORAGEDATE != null)
                    {
                        OUTSTORAGEDATE.Text = DateTime.Parse(pData.OUTSTORAGEDATE.ToString()).ToString("yyyy-MM-dd");
                    }
                    //库管员
                    if (pData.STOCKCONTROLLER ==null)
                    {
                        STOCKCONTROLLER.Visible = false;
                    }
                    //备注
                    if (pData.REMARKS ==null)
                    {
                        REMARKS.Visible = false;
                    }
                }
                //根据白卡出库单Id查询出库明细
                DataTable dt = DDAL.GetInfoByCheckId(pData.ID);
                rptDetailList.DataSource = dt;
                dt.DefaultView.Sort = "StartNo ASC,EndNo ASC";
                rptDetailList.DataBind();
            }
        }
    }
}